package com.sky.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;

@Configuration
public class RedisConfiguration {

    @Bean
    public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory){
        //创建redis模板类对象
        RedisTemplate redisTemplate = new RedisTemplate();
        //在模板中加入连接工厂
        redisTemplate.setConnectionFactory(redisConnectionFactory);
        //设置模板类的序列化转换器
        redisTemplate.setKeySerializer(redisTemplate.getStringSerializer());
        return  redisTemplate;
    }

}
